<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>用户列表</title>
    <link rel="stylesheet" href="${base}/layui/css/layui.css">
    <link rel="stylesheet" href="${base}/awesome/css/font-awesome.min.css">
     <link rel="stylesheet" href="${base}/css/admin.css">
    <style>
    	.layui-bg-black{        width: 200px;height: 136px;margin-right: 30px;float: left;text-align: center;font-size: 33px;color: #000000!important;padding-top: 30px;}
    	.hide {display: none;}
    	.checkbox{display: inline-block;}
    	.layui-form-item{font-size: 18px;}
    	.layui-input{display: inline-block;}
    	.width180 {width: 160px; margin-right: 5px;float: left;}
    	.layui-select{float: left;}
    	img{ max-width: 40%;}
    </style>
</head>
<body  class="layui-layout-body" style="overflow:scroll;">
<#include "/common/left.flt">	
<div class="layui-main" style="position: absolute;left: 205px;top: 20px; width: calc(100% - 210px);" >
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 40px;">
  <legend title="用户情况">操作提示 当前在线第三方${online_cnt?default('0')} &&& 当前在线A类用户${online_cnt_1?default('0')} <a class="layui-btn" id="online_x_1" title="批量1000 A类上线 6个月没登录的"> <span class="fa fa-bus"></span>批量1000 A类上线  6个月前没登录的(男)</a> <a class="layui-btn" id="online_x_2" title="批量100 A类上线 1个月没登录的"> <span class="fa fa-bus"></span>批量100 A类上线  1个月前没登录的(女)</a> </legend>
</fieldset>
<div class="layui-form hide" id="time" style="padding-top:20px;padding-right:20px;">
  <div class="layui-form-item">
    <label class="layui-form-label">时间</label>
    <div class="layui-input-block">
       <select name="disable_time" id="disable_time" class="layui-input layui-select" >
       	  <option value="1">1天</option>
          <option value="3">3天</option>
          <option value="7">7天</option>
          <option value="30">1月</option>
          <option value="90">3月</option>
          <option value="-1">永久</option>
       </select>
    </div>
  </div>
</div>
<div class="layui-form hide" id="hot" style="padding-top:20px;padding-right:20px;">
  <div class="layui-form-item">
    <label class="layui-form-label">热度</label>
    <div class="layui-input-block">
       <input name="hot_val" id="hot_val" type="number" min ="0" class="layui-input layui-text" />
    </div>
  </div>
  <div class="layui-form-item layui-form-text">
    <label class="layui-form-label">会员到期</label>
    <div class="layui-input-block">
      <input name="vip_end_time" id="vip_end_time" placeholder="" class="layui-input layui-text" />
    </div>
  </div>
  <div class="layui-form-item layui-form-text">
    <label class="layui-form-label">会员徽章</label>
    <div class="layui-input-block">
      <select name="vip_badpe1" id="vip_badpe1" class="width100 layui-select">
 				<option value="">无</option>
 				<option value="1">月度</option>
                <option value="2">季度</option>
                <option value="3">年度</option>
                <option value="4">永久</option>
		    </select>
    </div>
  </div>
</div>
<blockquote class="layui-elem-quote layui-quote-nm">
 	<form action="${base}/users_list/index" method="post" id="dataForm">
        <input type="hidden" id="page" name="page"/>
        <div class="layui-input-inline">
        	<input placeholder="五十度id" name ="user_id" class="layui-input width180" value="${user_id?default('')}" title="不带20开头的." />
 			<input placeholder="手机号" name ="user_mobile" class="layui-input width180" value="${user_mobile?default('')}" />
 			<label class="layui-form-label">性别:</label><select name="sex" id="sex" class="width100 layui-select">
 				<option value=""></option>
 				<option value="1">男</option>
                <option value="2">女</option>
                <option value="3">CD</option>
                <option value="4">FtM</option>
                <option value="5">MtF</option>
		    </select><label class="layui-form-label">地区:</label><select name="area" id="area" class="width100 layui-select">
 				<option value=""></option>
		      	<#list area_list as one>
		        <option value="${one.code}">${one.name}</option>
		        </#list>
		     </select><label class="layui-form-label">头像:</label><select name="header" id="header" class="width100 layui-select">
 				<option value=""></option>
 				<option value="1">有头像</option>
               	<option value="2">无头像</option>
		    </select><label class="layui-form-label">用户类别:</label><select name="is_true" id="is_true" class="width100 layui-select">
 				<option value="">不限</option>
 				<option value='1'>A类</option>
				<option value='2'>B类</option>
				<option value='3'>C类</option>
				<option value='4'>D类</option>
		      </select>
 	</div>
 	<div class="layui-input-inline">
 		<label class="layui-form-label">地区负责人</label><select name="person" id="person" class="width100 layui-select">
 				<option value=""></option>
 				<option value="1">袁杰</option>
                <option value="2">李扬</option>
                <option value="3">张炜</option>
                <option value="4">常少彪</option>
                <option value="100">强制清空</option>
		      </select>
		      <label class="layui-form-label">VIP类型</label><select name="vip_badpe" id="vip_badpe" class="width100 layui-select">
		        <option value="">不限</option>
 				<option value="0">无会员</option>
 				<option value="1">月度会员</option>
                <option value="2">季度会员</option>
                <option value="3">年度会员</option>
                <option value="4">终身会员</option>
		      </select>
		 <input placeholder="昵称" name ="nick_name" class="width180 layui-input" value="${nick_name?default('')}" />
		 
		 <input placeholder="min年龄" name ="minage" class="width180 layui-input" value="${minage?default('')}"  type="number" min="17" max="80"/>
		 
		 <input placeholder="max年龄" name ="maxage" class="width180 layui-input" value="${maxage?default('')}"  type="number" min="17" max="80"/>
		 
		 
		 <input placeholder="自定义标签" name ="zu" class="width180 layui-input" value="${zu?default('')}" />
    </div>
 	<div class="layui-form" style="display: inline-block;">
		<div class="layui-input-inline layui-form-item" >
	    <div class="layui-input-block">
	      <input type="checkbox" name="pre" <#if pre??>checked=""</#if> id="pre"  lay-skin="switch" lay-text="操作时间|否">
	      <input type="checkbox" name="gps" <#if gps??>checked=""</#if> id="gps"  lay-skin="switch" lay-text="位置|否">
	      <button class="layui-btn" lay-submit=""> <span class="fa fa-search"></span> 查询</button>
	      <a class="layui-btn" id="follow_x"> <span class="fa fa-random"></span>随机1~5个关注</a>
	      <a class="layui-btn" id="nick_name_x"> <span class="fa fa-random"></span>昵称违规</a>
	      <a class="layui-btn" id="message_x"> <span class="fa fa-smile-o"></span>给1个红点</a>
	      <a class="layui-btn" id="online_x"> <span class="fa fa-random"></span>批量上线</a>
	      <a class="layui-btn" id="move_gps_x" title="20公里内"> <span class="fa fa-random"></span>加2个女号</a>
	    </div>
		</div>
	</div>
    </form>
</blockquote> 
<table class="layui-table" >
	<thead>
        <tr>
             <th><input type="checkbox" id="all" />编号</th>
             <th>手机号</th>
             <th>昵称</th>
             <th>热度</th>
             <th>性别</th>
             <th>状态</th>
             <th>生日</th>
             <th>省份</th>
             <th>添加时间</th>
             <th>类型</th>
             <th>会员到期</th>
             <th>上次操作</th>
             <th>操作</th>
         </tr>
     </thead>
     <tbody>
     <#list page.list as one>
     <tr>
     	<td><input type="checkbox" name="id" value="${one.id}" /><a href="${base}/users_list/detail?user_id=${one.id}" target="_blank">${one.id}</a></td>
     	<td>${one.user_mobile?default('')}<#if one.qq_openid?exists><span class="fa fa-qq"></span></#if><#if one.wx_unionid?exists><span class="fa fa-weixin"></span></#if><#if one.apple_id?exists><span class="fa fa-apple"></span></#if></td>
     	<td>${one.nick_name?default('')}</td>
     	<td>${one.hot_val?default('0')}</td>
     	<td>${one.sex_name?default('')}</td>
     	<td><#if one.login_status == 0>当前在线<#else>${one.card_tag_ids?default('')}</#if>
     	</td>
     	<td><#if one.birthday_string?? >${one.birthday_string?default('')}</#if></td>
     	<td>${one.area_name?default('')}</td>
     	<td>${one.create_time_string} </td>
     	<td>${one.is_true_name}</td>
     	<td><#if one.vip_end_time?? ><#if one.vip_end_time gt 0 >${one.vip_end_time_string?default('')}</#if></#if> </td>
     	<th><#if one.up_time?? ><#if one.up_time gt 0 >${one.up_time_string?default('')}</#if></#if></th>
     	<td><a onclick="hot(${one.id},${one.hot_val?default('0')},'${one.vip_end_time_string?default('')}','${one.vip_badpe?default('0')}');" title="热度和会员时间修改" ><span class="fa fa-fire"></span></a> <a href="${base}/users_list/pack?user_id=${one.id}" target="_blank" title="增值服务充值" ><span class="fa fa-user-plus"></span></a>
     	<a onclick="time(${one.id});" title="禁用" ><span class="fa fa-times"></span></a> 
     	<a onclick="forbid_time(${one.id});" title="禁言" ><span class="fa fa-user-times"></span></a>
     	<a href="${base}/users_list/nearby?user_id=${one.id}" title="查看他附近的人" target="_blank"><span class="fa fa-map-marker"></span></a>
     	<a onclick="follow(${one.id});" title="关注" ><span class="fa fa-eye"></span></a>
     	<a onclick="random_follow(${one.id});" title="随机1~5个关注" ><span class="fa fa-random"></span></a>
     	<a onclick="black(${one.id});" title="拉黑" ><span class="fa fa-chain-broken"></span></a>
     	<a onclick="white(${one.id});" title="取消拉黑" ><span class="fa fa-chain"></span></a>
     	<a onclick="online(${one.id});" title="上线" ><span class="fa fa-sun-o"></span></a>
     	<a onclick="cancel_fans(${one.id});" title="取消关注" ><span class="fa fa-thumbs-o-down"></span></a>
     	</td>
     </tr>
     </#list>
     </tbody>
</table>
<div id="pageDiv"></div>
<form action="${base}/util/uploadFile" method="post" name="uploadForm" enctype="multipart/form-data" id="uploadForm" class="hide" >
    <input name="pic" type="file" id="pic" class="hide"/>
</form>
</body>
<script src="${base}/js/jquery-2.1.4.min.js" type="text/javascript"></script>
<script src="${base}/layui/layui.all.js"></script>
<script src="${base}/laydate/laydate.js"></script>
<script type="text/javascript">
$("#sex").val('${sex?default('')}');
$("#area").val('${area?default('')}');
$("#header").val('${header?default('')}');
$("#is_true").val('${is_true?default('')}');
$("#person").val('${person?default('')}');
$("#vip_badpe").val('${vip_badpe?default('')}');

$("#all").click(function (){
	if ($("#all").prop("checked")) {
		$("input[name='id']").prop("checked", true);
	} else {
		$("input[name='id']").prop("checked", false);
	}
});

layui.use('laypage',function () {
    var laypage = layui.laypage ;
    laypage.render({
        elem:"pageDiv",
        count:${page.totalPage*30},
        limit:30,
        curr:${page.pageNumber},
        layout:['count','prev','page','next','skip'],
        jump:function (obj,first) {
            var page = obj.curr;
            if(!first){
                $("#page").val(page);
                $("#dataForm").submit();
            }
        }
    });
});

function status_change(id){
	$.post("${base}/users_list/status",
	   		{"id":id},function(data){ 
	   			layer.alert(data);
	   			window.location.reload();
	   		}
	);  
}

function forbid_time(id){
	layer.open({
	    type: 1 ,
	    title: '禁言时间', 
	    area: ['400px', '300px'],   //宽高
	    shade: 0.6,   //遮罩透明度
	    content: $("#time"),
	    btn: ['确定'], //按钮组
	    scrollbar: false ,//屏蔽浏览器滚动条
	    yes: function(index){
	    	var disable_time = $("#disable_time").val();
	    	if (disable_time > 0) {
	    		$.post("${base}/users_list/forbid",
		    	   		{"id":id,"disable_time":disable_time},function(data){ 
		    	   			layer.msg(data);
		    	   			$("#time").hide();
		    	   		}
		    	 );		
	    	}
	        layer.close(index);
	        
	        $("#time").hide();
	    },
		cancel: function(){
			$("#time").hide();        
	    }
	});
}

function time(id){
	layer.open({
	    type: 1 ,
	    title: '禁用时间', 
	    area: ['400px', '300px'],   //宽高
	    shade: 0.6,   //遮罩透明度
	    content: $("#time"),
	    btn: ['确定'], //按钮组
	    scrollbar: false ,//屏蔽浏览器滚动条
	    yes: function(index){
	    	var disable_time = $("#disable_time").val();
    		$.post("${base}/users_list/disable",
			   		{"id":id,"disable_time":disable_time},function(data){ 
			   			layer.alert(data);
			   			$("#time").hide();
			   		}
			 );	
	        layer.close(index);
	        
	        $("#time").hide();
	    },
		cancel: function(){
			$("#time").hide();        
	    }
	});
}


function hot(id,hot_val,vip_end_time,vip_badpe){
	$("#hot_val").val(hot_val);
	$("#vip_badpe1").val(vip_badpe);
	
	layui.use('form', function() {
	    var form = layui.form;
	    form.render('select');
	});

	
	layui.use('laydate', function(){
		  var laydate = layui.laydate;
		  //执行一个laydate实例
		  laydate.render({
		    elem: '#vip_end_time' //指定元素
		    ,value: vip_end_time
		  });
	});
	
	layer.open({
	    type: 1 ,
	    title: '热度和会员到期修改', 
	    area: ['600px', '400px'],   //宽高
	    shade: 0.4,   //遮罩透明度
	    content: $("#hot"),
	    btn: ['确定'], //按钮组
	    scrollbar: false ,//屏蔽浏览器滚动条
	    yes: function(index){
	    	var hot_val = $("#hot_val").val();
	    	var vip_end_time = $("#vip_end_time").val();
	    	var vip_badpe1 = $("#vip_badpe1").val();
	    	
    		$.post("${base}/users_list/hot_pro",
			   		{"hot_val":hot_val,"id":id,"vip_end_time":vip_end_time,"vip_badpe":vip_badpe1},function(data){ 
			   			layer.alert(data);
			   			$("#hot").hide();
			   		}
			 );	
	        layer.close(index);
	        
	        $("#hot").hide();
	    },
		cancel: function(){
			$("#hot").hide();        
	    }
	});
}

function online(id){
	$.post("${base}/users_list/online",
	   		{"ids":id},function(data){ 
	   			layer.msg(data);
	   		}
	    );
}

$("#online_x").click(function(){
	 try {
		 var ids = "";
			$('input[name="id"]:checked').each(function(){//遍历每一个名字为interest的复选框，其中选中的执行函数    
				ids = ids + $(this).attr("value")+",";
		    });
			if(ids){
				$.post("${base}/users_list/online",
				   		{"ids":ids},function(data){ 
				   			layer.msg(data);
				   		}
				    );
			}
    }catch(e) {
       console.log(e)
    }
});
$("#move_gps_x").click(function(){
	 try {
		 var ids = "";
			$('input[name="id"]:checked').each(function(){//遍历每一个名字为interest的复选框，其中选中的执行函数    
				ids = ids + $(this).attr("value")+",";
		    });
			if(ids){
				$.post("${base}/users_list/move_gps_2",
				   		{"ids":ids},function(data){ 
				   			layer.msg(data);
				   		}
				    );
			}
   }catch(e) {
      console.log(e)
   }
});


$("#online_x_1").click(function(){
	$.post("${base}/users_list/online_1",
	   		{},function(data){ 
	   			layer.msg(data);
	   		}
	    );
});

$("#online_x_2").click(function(){
	$.post("${base}/users_list/online_2",
	   		{},function(data){ 
	   			layer.msg(data);
	   		}
	    );
});

function random_follow(id){
	$.post("${base}/users_list/giveFollow2",
	   		{"user_id":id},function(data){ 
	   			layer.msg(data);
	   		}
	    );
}
$("#follow_x").click(function(){
	 try {
		 var ids = "";
			$('input[name="id"]:checked').each(function(){//遍历每一个名字为interest的复选框，其中选中的执行函数    
				ids = ids + $(this).attr("value")+",";
		    });
			if(ids){
				$.post("${base}/users_list/giveFollow3",
				   		{"ids":ids},function(data){ 
				   			layer.msg(data);
				   		}
				    );
			}
     }catch(e) {
        console.log(e)
     }
});
$("#nick_name_x").click(function(){
	 try {
		 var ids = "";
			$('input[name="id"]:checked').each(function(){//遍历每一个名字为interest的复选框，其中选中的执行函数    
				ids = ids + $(this).attr("value")+",";
		    });
			if(ids){
				$.post("${base}/users_list/giveNickNameRule",
				   		{"ids":ids},function(data){ 
				   			layer.msg(data);
				   		}
				    );
			}
    }catch(e) {
       console.log(e)
    }
});
$("#message_x").click(function(){
	 try {
		 var ids = "";
			$('input[name="id"]:checked').each(function(){//遍历每一个名字为interest的复选框，其中选中的执行函数    
				ids = ids + $(this).attr("value")+",";
		    });
			if(ids){
				$.post("${base}/users_list/giveMessage",
				   		{"ids":ids},function(data){ 
				   			layer.msg(data);
				   		}
				    );
			}
    }catch(e) {
       console.log(e)
    }
});

function follow(id){
	layer.prompt({title: '请输入关注数量，并确认', formType: 2}, function(content, index){
		$.post("${base}/card_list/giveFollow2",
		   		{"user_id":id,"num":content},function(data){ 
		   			layer.msg(data);
		   		}
		    );
		layer.close(index);
    });	
}

function cancel_fans(id){
	$.post("${base}/users_list/cancel_fans",
	   		{"user_id":id},function(data){ 
	   			layer.msg(data);
	   		}
	);
}

function black(id){
	layer.prompt({
		  formType: 0,
		  value: '0',
		  title: '拉黑人的id',
		  area: ['400px', '300px']
	}, function(value, index, elem){
		  //alert(value); //得到value
		  $.post("${base}/users_list/black",
			   		{"user_id":value,"black_user_id":id},function(data){ 
			   			layer.msg(data);
			   		}
			);
		  layer.close(index);
	});
	
	
}

function white(id){
	layer.prompt({
		  formType: 0,
		  value: '0',
		  title: '拉黑人的id',
		  area: ['400px', '300px']
	}, function(value, index, elem){
		  
		  $.post("${base}/users_list/white",
			   		{"user_id":value,"black_user_id":id},function(data){ 
			   			layer.msg(data);
			   		}
			);
		  layer.close(index);
	});
	
	
}
</script>
</html>